<?php

	class File extends CWidget
	{
	
		public function run()
		{
			$file=new Files();
				if (isset($_POST['ajax'])&& $_POST['ajax']==='file')
			            {
			            	
			                # code...
			                echo CActiveForm::validate($reguser);
			                Yii::app()->end();
			            }
		   
		        if (isset($_POST['Files'])) 
		        {
		        	
		        	 $file->attributes=$_POST['Files'];
		        	 $file->name = CUploadedFile::getInstance($file,'name'); 
		        	      $file->date=date('Y-m-d H:i:s');
		        		     	
						
		        if ($file->validate('reg'))
					{
						
						
						 
						 $Rassh=preg_split('/[.]+/',$file->name, -1, PREG_SPLIT_NO_EMPTY); 
						 $temp=mktime(date("s"),date("Y"),date("m"),date("d"));
							$file->name->saveAs('file/'.$temp.".".$Rassh[1]);
							$file->name=$temp.".".$Rassh[1];
						
						if($file->save())
						 {	
						 
						 	//$this->redirect("/admin/qinformation/list/");
						echo "<a href='/file/".$file->name."'>".$file->text."</a>";
						 }
					}
		        	
		        }
				
					
					$this->render('file',array('file'=>$file));
		}
		
	
	}
?>